package excel

import (
	"fmt"
	inf "github.com/fzdwx/infinite"
	"github.com/fzdwx/infinite/color"
	"github.com/fzdwx/infinite/components"
	"github.com/fzdwx/infinite/components/selection/singleselect"
	"github.com/fzdwx/infinite/style"
)

func (e *Excel) ShowSheetListAndSelect() {
	//for i, SheetName := range e.GetSheetList() {
	//	println(i, SheetName)
	//}
	SheetList := e.GetSheetList()
	input := components.NewInput()
	input.Prompt = "输入关键词进行过滤: "
	input.PromptStyle = style.New().Bold().Italic().Fg(color.LightBlue)
	//
	choice, _ := inf.NewSingleSelect(SheetList,
		singleselect.WithFilterInput(input),
	).Display("选择一张表！")
	fmt.Println(">>> ", choice, SheetList[choice])
}

func (e *Excel) PrintSheetDataEasy(SheetData [][]string, err error) {
	if err != nil {
		fmt.Println("获取数据遇到错误，原因：", err)
	}
	//if len(SheetData) == 0 {
	//	return
	//}
	//ColNum := 1
	//var ColWidth map[int]int
	//width := 10
	//for i := 0; i < len(SheetData); i++ {
	//	fmt.Println(len(SheetData[i]))
	//	for j := 0; j < len(SheetData[i]); j++ {
	//		if len(SheetData[i][j]) > width {
	//			SheetData[i][j] = SheetData[i][j][:width-3] + "..."
	//		} else if len(SheetData[i][j]) < width {
	//			SheetData[i][j] = SheetData[i][j] + strings.Repeat("", width-len(SheetData[i][j]))
	//		}
	//	}
	//}
	////for _, datum := range SheetData {
	////	fmt.Println(datum)
	////}
}
